class User {
  String? token;
  String? sex;
  String? userLogo;
  int? orgUserId;
  String? userName;
  bool? isOrg;
  List<OrgInfoList>? orgInfoList;
  int? userStatus;
  bool? logout;

  User(
      {this.token,
      this.sex,
      this.userLogo,
      this.orgUserId,
      this.userName,
      this.isOrg,
      this.orgInfoList,
      this.userStatus,
      this.logout});

  User.fromJson(Map<String, dynamic> json) {
    if (json["token"] is String) {
      token = json["token"];
    }
    if (json["sex"] is String) {
      sex = json["sex"];
    }
    if (json["userLogo"] is String) {
      userLogo = json["userLogo"];
    }
    if (json["orgUserId"] is int) {
      orgUserId = json["orgUserId"];
    }
    //兼容Android orgUserId字段为String
    if (json["orgUserId"] is String) {
      var temp = json["orgUserId"] as String;
      orgUserId = int.parse(temp);
    }
    if (json["userName"] is String) {
      userName = json["userName"];
    }
    if (json["isOrg"] is bool) {
      isOrg = json["isOrg"];
    }
    if (json["orgInfoList"] is List) {
      orgInfoList = json["orgInfoList"] == null
          ? null
          : (json["orgInfoList"] as List)
              .map((e) => OrgInfoList.fromJson(e))
              .toList();
    }
    if (json["userStatus"] is int) {
      userStatus = json["userStatus"];
    }
    //兼容Android userStatus字段为String
    if (json["userStatus"] is String) {
      var temp = json["userStatus"] as String;
      userStatus = int.parse(temp);
    }

    if (json["logout"] is bool) {
      logout = json["logout"];
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> _data = <String, dynamic>{};
    _data["token"] = token;
    _data["sex"] = sex;
    _data["userLogo"] = userLogo;
    _data["orgUserId"] = orgUserId;
    _data["userName"] = userName;
    _data["isOrg"] = isOrg;
    if (orgInfoList != null) {
      _data["orgInfoList"] = orgInfoList?.map((e) => e.toJson()).toList();
    }
    _data["userStatus"] = userStatus;
    _data["logout"] = logout;
    return _data;
  }
}

class OrgInfoList {
  String? userName;
  String? orgLogo;
  String? orgName;
  String? userLogo;
  int? orgId;

  OrgInfoList(
      {this.userName, this.orgLogo, this.orgName, this.userLogo, this.orgId});

  OrgInfoList.fromJson(Map<String, dynamic> json) {
    if (json["userName"] is String) {
      userName = json["userName"];
    }
    if (json["orgLogo"] is String) {
      orgLogo = json["orgLogo"];
    }
    if (json["orgName"] is String) {
      orgName = json["orgName"];
    }
    if (json["userLogo"] is String) {
      userLogo = json["userLogo"];
    }
    if (json["orgId"] is int) {
      orgId = json["orgId"];
    }
    //兼容Android orgId字段为String
    if (json["orgId"] is String) {
      var temp = json["orgId"] as String;
      orgId = int.parse(temp);
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> _data = <String, dynamic>{};
    _data["userName"] = userName;
    _data["orgLogo"] = orgLogo;
    _data["orgName"] = orgName;
    _data["userLogo"] = userLogo;
    _data["orgId"] = orgId;
    return _data;
  }
}
